<?php

declare(strict_types=1);

namespace App\Controller;

use Hyperf\HttpServer\Annotation\AutoController;
use Hyperf\HttpServer\Contract\RequestInterface;
use Hyperf\HttpServer\Contract\ResponseInterface;
use Hyperf\Di\Annotation\Inject;

/**
 * @AutoController()
 * Class SessionController
 * @package App\Controller
 */
class SessionController extends AbstractController
{

    /**
     * @Inject()
     * @var \Hyperf\Contract\SessionInterface
     */
    private $session;

    public function index(RequestInterface $request, ResponseInterface $response)
    {
        $this->session->set('foo', 'bar');
        $data = $this->session->get('foo', $default = null);
        return $response->raw($data);
    }
}
